//
//  LPZWYCCTableHeaderView.m
//  ZhongWangYuan
//
//  Created by liuyingping on 2018/6/2.
//  Copyright © 2018年 ZJ. All rights reserved.
//

#import "LPZWYCCTableHeaderView.h"


@implementation LPZWYCCTableHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.headline = [UILabel new];
        self.headline.textColor = [UIColor textBlackColor];
        self.headline.font = LYPFONT(16);
        [self addSubview:self.headline];
        self.headline.sd_layout
        .centerYEqualToView(self)
        .leftSpaceToView(self, 15 * [UIScreen zj_screenHScale])
        .heightIs(20 * [UIScreen zj_screenHScale])
        .widthIs([UIScreen zj_screenWith] * 0.5);
        
        self.moreButton = [UIButton new];
        [self.moreButton setTitle:@"更多" forState:UIControlStateNormal];
        [self.moreButton setImage:[UIImage imageNamed:@"icon_more_s"] forState:UIControlStateNormal];
        self.moreButton.titleLabel.font = LYPFONT(13);
        [self.moreButton setTitleColor:[UIColor themeColor] forState:UIControlStateNormal];
        [self addSubview:self.moreButton];
        self.moreButton.sd_layout
        .rightSpaceToView(self, 15 * [UIScreen zj_screenWScale])
        .centerYEqualToView(self)
        .widthIs(60 * [UIScreen zj_screenWScale])
        .heightIs(20 * [UIScreen zj_screenHScale]);
        
        CGFloat imageWidth = self.moreButton.imageView.bounds.size.width;
        CGFloat labelWidth = self.moreButton.titleLabel.bounds.size.width;
        self.moreButton.imageEdgeInsets = UIEdgeInsetsMake(0, labelWidth, 0, -labelWidth);
        self.moreButton.titleEdgeInsets = UIEdgeInsetsMake(0, -imageWidth, 0, imageWidth);
        
        [self.moreButton addTarget:self action:@selector(clickButton) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return self;
}

- (void)clickButton{
    if (self.delegate) {
        [self.delegate LPZWYCCTableHeaderView_clickMore:self.section];
    }
}

@end
